APM.ConfigConfmanageController = Ember.Controller.extend({
	form: {
		confFile:"",
		confType:"13"
	},    
	
	checkFormValid: function(){
		var form = this.get("form");
		
		this.set("saveResult", null);
		
		if( form.confFile == "" ){
			this.set("formTip", "请选择要导入的配置文件!");
			return false;
		}
		this.set("formTip", null);
		return true;
	},
	
	actions: {
		reset : function() {
			this.set("formTip", null);
			this.set("saveResult", null);
			
		},
		
		factorySetting: function(){
			alert("恢复出厂配置");
			var ctrl = this;
			var form = this.get("form");

			ctrl.set("saveResult", null);

			this.store.ajax("POST", "configs/systemConfig", {
				confFile: form.confFile,
				confType:form.confType
			}).then(function(response){
				if(response.status=="success"){
					//todo: 保存成功逻辑
					ctrl.set("saveResult", "保存成功！");
				}
			}, function(){
				ctrl.set("saveResult", "保存失败！");
			});
		},
		
		leadOutFile: function(){
			alert("导出配置文件");
			var ctrl = this;

			this.store.ajax("POST", "configs/systemConfig", {
				
			});
		},
		
		userSetting: function(){
			if( !this.checkFormValid() ){
				return;
			}
			alert("恢复用户配置");
			var ctrl = this;
			var form = this.get("form");

			ctrl.set("saveResult",null);

			this.store.ajax("POST", "configs/systemConfig", {
				confFile: form.confFile
			}).then(function(response){
				if(response.status=="success"){
					//todo: 保存成功逻辑
					ctrl.set("saveResult", "恢复成功！");
				}
			}, function(){
				ctrl.set("saveResult", "恢复失败！");
			});
		}
		
	}
	
});